﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Custom="http://schemas.microsoft.com/wpf/2008/toolkit">
	<!-- Resource dictionary entries should be defined here. -->
	<Style x:Key="DataGridSetup" TargetType="{x:Type Custom:DataGrid}">
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="BorderBrush" Value="#FF688CAF"/>
		<Setter Property="BorderThickness" Value="1,1,1,1"/>
		<Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
		<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Custom:DataGrid}">
					<Border SnapsToDevicePixels="True" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" BorderBrush="#FF275079">
						<Border.Background>
							<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
								<GradientStop Color="#FFFFFFFF" Offset="0"/>
								<GradientStop Color="#FFDEDEDE" Offset="1"/>
							</LinearGradientBrush>
						</Border.Background>
						<ScrollViewer Focusable="False" x:Name="DG_ScrollViewer">
							<ScrollViewer.Template>
								<ControlTemplate TargetType="{x:Type ScrollViewer}">
									<Grid>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto"/>
											<RowDefinition Height="*"/>
											<RowDefinition Height="Auto"/>
										</Grid.RowDefinitions>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="Auto"/>
											<ColumnDefinition Width="*"/>
											<ColumnDefinition Width="Auto"/>
										</Grid.ColumnDefinitions>
										<Button Focusable="False" Width="{Binding Path=CellsPanelHorizontalOffset, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Custom:DataGrid}}}">
											<Button.Command>
												<RoutedCommand/>
											</Button.Command>
											<Button.Visibility>
												<Binding Path="HeadersVisibility" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Custom:DataGrid}}">
													<Binding.ConverterParameter>
														<Custom:DataGridHeadersVisibility>All</Custom:DataGridHeadersVisibility>
													</Binding.ConverterParameter>
												</Binding>
											</Button.Visibility>
											<Button.Template>
												<ControlTemplate TargetType="{x:Type Button}">
													<Grid>
														<Rectangle SnapsToDevicePixels="True" x:Name="Border" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
														<Polygon Opacity="0.15" HorizontalAlignment="Right" Margin="8,8,3,3" x:Name="Arrow" VerticalAlignment="Bottom" Fill="#FF000000" Stretch="Uniform" Points="0,10 10,10 10,0"/>
													</Grid>
													<ControlTemplate.Triggers>
														<Trigger Property="IsMouseOver" Value="True">
															<Setter Property="Stroke" TargetName="Border" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
														</Trigger>
														<Trigger Property="IsPressed" Value="True">
															<Setter Property="Fill" TargetName="Border" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
														</Trigger>
														<Trigger Property="IsEnabled" Value="False">
															<Setter Property="Visibility" TargetName="Arrow" Value="Collapsed"/>
														</Trigger>
													</ControlTemplate.Triggers>
												</ControlTemplate>
											</Button.Template>
										</Button>
										<Custom:DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1">
											<Custom:DataGridColumnHeadersPresenter.Visibility>
												<Binding Path="HeadersVisibility" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Custom:DataGrid}}">
													<Binding.ConverterParameter>
														<Custom:DataGridHeadersVisibility>Column</Custom:DataGridHeadersVisibility>
													</Binding.ConverterParameter>
												</Binding>
											</Custom:DataGridColumnHeadersPresenter.Visibility>
										</Custom:DataGridColumnHeadersPresenter>
										<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.ColumnSpan="2" Grid.Row="1" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False"/>
										<ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" x:Name="PART_VerticalScrollBar" Grid.Column="2" Grid.Row="1" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
										<Grid Grid.Column="1" Grid.Row="2">
											<Grid.ColumnDefinitions>
												<ColumnDefinition Width="{Binding Path=NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Custom:DataGrid}}}"/>
												<ColumnDefinition Width="*"/>
											</Grid.ColumnDefinitions>
											<ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" x:Name="PART_HorizontalScrollBar" Grid.Column="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
										</Grid>
									</Grid>
								</ControlTemplate>
							</ScrollViewer.Template>
							<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
						</ScrollViewer>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Style.Triggers>
			<Trigger Property="IsGrouping" Value="True">
				<Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
			</Trigger>
		</Style.Triggers>
	</Style>
</ResourceDictionary>